//
//  HomeInfoSleepView.m
//  Ginix
//
//  Created by 冯志强 on 2025/3/16.
//

#import "HomeInfoSleepView.h"

@interface HomeInfoSleepView()
@property (nonatomic,strong) UIImageView * bgView;
@property (nonatomic,strong) UIImageView * iconView;
@property (nonatomic,strong) UILabel * infoLabel;
@end

@implementation HomeInfoSleepView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setSubViewLayout];
    }
    return self;
}

-(void)setSubViewLayout{
    
    [self addSubview:self.bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).insets(UIEdgeInsetsMake(0 * FMScaleX, 0 * FMScaleX, 0 * FMScaleX, 0 * FMScaleX));
    }];
    [self addSubview:self.iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(100 * FMScaleX, 16 * FMScaleX));
        make.left.mas_offset(30 * FMScaleX);
        make.top.mas_offset(26 * FMScaleX);
    }];
    [self addSubview:self.infoLabel];
    [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(@0);
        make.top.equalTo(self.iconView.mas_bottom).offset(10 * FMScaleX);
        make.width.mas_offset(280 * FMScaleX);
    }];
}

-(void)setInfoModel:(HomeSleepModel *)infoModel{
    
    self.infoLabel.text = infoModel.analysis;
    
}

-(UIImageView *)bgView{
    
    if (!_bgView) {
        _bgView = [[UIImageView alloc]init];
        _bgView.image = [UIImage imageNamed:@"Home_info_slepp_bg"];
        _bgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _bgView;
}
-(UIImageView *)iconView{
    
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
        _iconView.image = [UIImage imageNamed:@"Home_info_slepp_icon"];
    }
    return _iconView;
}

-(UILabel *)infoLabel{
    
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc]init];
        _infoLabel.font = Regular(12);
        _infoLabel.textColor = RDRGB(0xAD7D62);
        _infoLabel.numberOfLines = 0;
    }
    return _infoLabel;
}

@end
